import React, { useState } from "react";
import { Upload, Button } from "antd";
import { UploadChangeParam, UploadFile } from "antd/es/upload";

function App() {
  const [url, setUrl] = useState('')
  const handleChange = (e: UploadChangeParam<UploadFile<any>>) => {
    const resp = e.file.response
    if(resp) {
      console.log(resp.data.url)
      setUrl(resp.data.url)
    }
  }
  return (
    <div className="App">
      <Upload action="/upload" method="post" onChange={e => handleChange(e)}>
        <Button type="primary">上传文件</Button>
      </Upload>
      <img src={url} alt="" height={300}/>
    </div>
  );
}

export default App;
